package com.library.dao;

import java.sql.DriverManager;
import java.sql.SQLException;

import com.mysql.jdbc.Connection;

public class MySQLConnection {

	public static Connection getConnection(){
		Connection conn;
		try {
			Class.forName("com.mysql.jdbc.Driver");
			conn = (Connection) DriverManager.getConnection(
					"jdbc:mysql://localhost:3306/librarysystem?useUnicode=true&characterEncoding=UTF-8", "library",
					"12345678");

		} catch (SQLException | ClassNotFoundException e) {
			conn = null;
		}
		return conn;
	}
	
	public static void closeConnection(Connection conn){
		try {
			conn.close();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
